package com.CoreryBlack.Mapper;

import com.CoreryBlack.po.Clazz;
import com.CoreryBlack.po.ClazzQueryParam;
import com.CoreryBlack.po.Student;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

/**
 * @Description ClazzMapper
 * @Author CoreryBlack
 * @Date 2024-09-19
 */

@Mapper

public interface ClazzMapper {
    @Select("select id,name,room,begin_date,end_date,master_id,subject,create_time,update_time from clazz")
    public List<Clazz> findAll();

    @Delete("delete from clazz where id=#{id}")
    void deleteById(Integer id);

    Page<Clazz> list(ClazzQueryParam clazzQueryParam);

    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into clazz(name,room,begin_date,end_date,master_id,subject,create_time,update_time) values " +
            "(#{name},#{room},#{beginDate},#{endDate},#{masterId},#{subject},#{createTime},#{updateTime})")
    void insert(Clazz clazz);

    void updateClazz(Clazz clazz);

    Clazz queryById(Integer id);

    Clazz getInfo(Integer id);

    @MapKey("clazzList")
    List<Map<String, Object>> countStudentCountData();

        // 其他方法...

    @Select("SELECT COUNT(*) FROM student WHERE clazz_id = #{clazzId}")
    int countStudentsByClazzId(Integer clazzId); // 查询该班级的学生数量

}